package com.aaa.controller;

import com.aaa.entity.R;
import com.aaa.service.Impl.Server;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务器监控
 *
 */
@RestController
@RequestMapping("/monitor/server")
public class ServerController
{

    /**
     * 查询系统详情
     */
    @GetMapping("/info")
    public R getInfo() throws Exception
    {
        Server server = new Server();
        server.copyTo();
        return R.ok().entity(server);
    }

    /**
     * 查询cpu信息
     */
    @GetMapping("/cpu")
    public R getCpu() throws Exception
    {
        Server server = new Server();

        return R.ok().entity(server.cpu());
    }

    /**
     * 查询内存信息
     */
    @GetMapping("/mem")
    public R getMem() throws Exception
    {
        Server server = new Server();

        return R.ok().entity(server.mem());
    }

    /**
     * 查询jvm信息
     */
    @GetMapping("/jvm")
    public R getJvm() throws Exception
    {
        Server server = new Server();
        return R.ok().entity(server.jvm());
    }

    /**
     * 查询系统信息
     */
    @GetMapping("/sys")
    public R getSys() throws Exception
    {
        Server server = new Server();
        return R.ok().entity(server.sys());
    }

    /**
     * 查询硬盘信息
     */
    @GetMapping("/sysFiles")
    public R getSysFiles() throws Exception
    {
        Server server = new Server();
        return R.ok().entity(server.sysFiles());
    }
}
